package kr.hkit.androidcomplete01.chapter07;

import kr.hkit.androidcomplete01.R;
import android.app.Activity;
import android.graphics.Color;
import android.graphics.RadialGradient;
import android.graphics.Shader.TileMode;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class ShapeDrawableEx extends Activity {
	Button lBtn;
	Button cBtn;
	Button rBtn;
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch07_shapedrawableex);
		
		lBtn = (Button) findViewById(R.id.ch07_leftBtn);
		cBtn = (Button) findViewById(R.id.ch07_centerBtn);
		rBtn = (Button) findViewById(R.id.ch07_rightBtn);
	}
	
	public void mOnClick(View v){
		switch(v.getId()){
		case R.id.ch07_leftBtn:
			lBtn.setBackgroundResource(R.drawable.shape2);
			break;
		case R.id.ch07_centerBtn:
			cBtn.setBackgroundResource(R.drawable.shape3);
			break;
		case R.id.ch07_rightBtn:
			ShapeDrawable sd = new ShapeDrawable(new OvalShape());
			sd.getPaint().setShader(new RadialGradient(60, 30, 50, Color.WHITE, Color.BLACK, TileMode.CLAMP));
			rBtn.setBackground(sd);
			break;
		}
	}
}
